package sink

import (
	"database/sql"
	"gomuisc/models/music"
)


func (sink MysqlSink) InsertComment(comment music.MusicComments) (err error) {
	_, err = sink.database.Exec("insert into yunyinyue(content, song_id,user_id,nickname,avatarURL,comment_id,createtime) values (?,?,?,?,?,?,?)",
		comment.Content, comment.SongId,comment.UserId,comment.Nickname,comment.AvatarUrl,comment.CommentId,comment.Createtime)
	if err != nil {
		return
	}
	//err = sink.InsertYunyinyueUser(comment.User)
	return

}
func (sink MysqlSink) GetComment(comment music.MusicComments)(row map[string]int,err error){
	var song_id  int
	var comment_id  int
	err = sink.database.QueryRow("select song_id,comment_id from yunyinyue where song_id = ? and comment_id = ?  ",
		comment.SongId,comment.CommentId).Scan(&song_id,&comment_id)
	//return row
	if err == sql.ErrNoRows {
		return nil, err
	} else {
		row["song_id"] = song_id
		row["comment_id"] = comment_id
	}
	return
}
